home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 2: CDPD 1 / Almathera Ten on Ten - Disc 2: CDPD 1.iso / pd / 051-075 / 069 / spool / dates.c next >
Text File  |  1995-03-13  |  714b  |  26 lines

  1. /* juldate.c - convert dates */
  2.  
  3. Julian_to_Gregorian(inday, year, month, day)  /* julian day to month and day */
  4. register short int inday;
  5. int  *year, *month, *day;
  6. {
  7.    register short int leap_year, m;
  8.    static short month_days[] = {       /* in leap year */
  9.         0,  31,  60,  91, 121, 152,
  10.       182, 213, 244, 274, 305, 335, 366};
  11. #define APRIL 92
  12. #define JUNE 183
  13. #define SEPTEMBER 275
  14.  
  15.    leap_year = ((*year % 4) == 0);   /* approximately */
  16.    if (!leap_year && (inday > 59)) inday++;
  17.    if (inday < JUNE)
  18.      m = (inday < APRIL) ? 0 : 3;
  19.    else
  20.      m = (inday < SEPTEMBER) ? 6 : 9;
  21.  
  22.    for ( ; inday > month_days[m]; m++);   /* find month */
  23.    *day = inday - month_days[m-1] + 1;
  24.    *month = m;
  25. }
  26.